package com.example.demo.yuy.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 描述
 *
 * @author: yuy
 */
@RestController
public class RedisController {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    //添加
    @GetMapping(path="/redisAdd")
    public void saveRedis(){
        stringRedisTemplate.opsForValue().set("a","test1");
    }

    //获取
    @GetMapping(value="/redisGet")
    public String getRedis(){
        return stringRedisTemplate.opsForValue().get("a");
    }

}
